﻿using System.Data;

namespace ReportExportTest.Provider
{
    public class ToolProvider
    {
        /// <summary>
        /// 模拟报表数据
        /// </summary>
        /// <returns></returns>
        public static DataTable GetDataTable()
        {
            DataTable reportData = new DataTable("销售报表");
            reportData.Columns.Add("产品名称", typeof(string));
            reportData.Columns.Add("销售数量", typeof(int));
            reportData.Columns.Add("单价", typeof(decimal));
            reportData.Columns.Add("销售总额", typeof(decimal));

            var random = new Random();
            // 模拟一些报表数据
            for (int i = 0; i < 1000; i++)
            {
                var name = Guid.NewGuid().ToString();
                var num = random.Next(1000);
                decimal price = (decimal)random.Next(10000) / 100;
                reportData.Rows.Add("产品" + name, num, price, num * price);
            }
            return reportData;
        }
    }
}
